package job

import (
	"context"
	"time"
	"webook/internal/service"
)

type RankingJob struct {
	svc service.RankingService
}

func NewRankingJob(svc service.RankingService) Job {
	return &RankingJob{
		svc: svc,
	}
}

func (job *RankingJob) Name() string {
	return "ranking"
}

func (job *RankingJob) Run() error {
	// 计算TopN热榜数据
	ctx, cancel := context.WithTimeout(context.Background(), time.Minute*3)
	defer cancel()
	return job.svc.TopN(ctx, 10)
}
